<template>
  <div class="comment-reply">
    <van-nav-bar :title="comment.reply_count>0?`${comment.reply_count}条回复`:'暂无回复'">
        <van-icon slot="left" name="cross" @click="$emit('update:close',false)"/>
    </van-nav-bar>
    <div class="scroll-wrap">
      <!-- 当前评论项目 -->
      <commentItem :comment="comment"/>
      <!-- 当前评论项目 -->
      <!-- 评论的回复列表 -->
      <commentList :type="'c'" :source="comment.com_id" :list="replyList"/>
      <!-- 评论的回复列表 -->
    </div>
    <!-- 写评论按钮 -->
    <div class="reply-warp">
      <van-button class="reply-btn" size="small" @click="isReplyShow = true">写评论</van-button>
    </div>
    <!-- 写评论按钮 -->
    <!-- 写评论回复弹出层 -->
    <van-Popup v-model="isReplyShow" position="bottom">
      <comment-post  @replySuccessPost="replySuccessPost" :target="comment.com_id"/>
    </van-Popup >
    <!-- 写评论回复弹出层 -->
  </div>
</template>

<script>
import commentItem from '../comment-item'
import commentList from '../comment-list'
import commentPost from '../comment-post'
export default {
  name: 'CommentReply',
  components: { commentItem, commentList, commentPost },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      isReplyShow: false,
      replyList: []
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    replySuccessPost (newObj) {
      this.isReplyShow = false
      console.log(11)
      console.log(newObj)
      this.replyList.unshift(newObj)
      this.comment.reply_count++
    }
  }
}
</script>

<style lang="less" scoped>
.scroll-wrap{
  position: fixed;
  top: 92px;
  bottom: 88px;
  left: 0;
  right: 0;
  overflow: auto;
}
  .reply-warp{
    background-color: #fff;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 88px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #d8d8d8;
    .reply-btn{
      width: 60%;
    }
  }
</style>
